package com.cyt.web.controller.work.kwmanagement;

import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.StringUtils;
import com.cyt.sys.util.EasyPoiUtil;
import com.cyt.work.kwmanagement.model.vo.KwTeacherJkStaticVo;
import com.cyt.work.kwmanagement.model.vo.KwTeacherMessageVo;
import com.cyt.work.kwmanagement.model.vo.KwTeacherStExportVo;
import com.cyt.work.kwmanagement.service.KwTeacherMessageService;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 考务教师表详细表-考务教师表详细表控制层
 *
 * @author han jun
 * @date 2019-11-26 11:25:40
 */
@RestController
public class KwTeacherMessageController extends BaseController {

    @Resource
    private KwTeacherMessageService kwTeacherMessageService;
    
    /**
     * 统一跳转
     *
     * @param model 数据模型
     * @return Model
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @RequestMapping("/work/kwmanagement/kwteachermessage/*")
    public Model goPage(Model model) {
        return model;
    }

    /**
     * 分页查询
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/findPage", method = RequestMethod.POST)
    public ReturnResult findPage(KwTeacherMessageVo kwTeacherMessageVo, int page, int limit) {
        return kwTeacherMessageService.findPage(kwTeacherMessageVo, page, limit);
    }

    /**
     * 分页查询
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @param page 分页数
     * @param limit 每页显示条数
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/findVoPage", method = RequestMethod.POST)
    public ReturnResult findVoPage(KwTeacherMessageVo kwTeacherMessageVo, int page, int limit) {
        return kwTeacherMessageService.findVoPage(kwTeacherMessageVo, page, limit);
    }

    /**
     * list查询
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "list查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/findList", method = RequestMethod.POST)
    public ReturnResult findList(KwTeacherMessageVo kwTeacherMessageVo) {
        return new ReturnResult(kwTeacherMessageService.findList(kwTeacherMessageVo));
    }

    /**
     * list查询
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "list查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/findVoList", method = RequestMethod.POST)
    public ReturnResult findVoList(KwTeacherMessageVo kwTeacherMessageVo) {
        return new ReturnResult(kwTeacherMessageService.findVoList(kwTeacherMessageVo));
    }

    /**
     * 单个对象查询
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/findOne", method = RequestMethod.POST)
    public ReturnResult findOne(KwTeacherMessageVo kwTeacherMessageVo) {
        return new ReturnResult(kwTeacherMessageService.findOne(kwTeacherMessageVo));
    }

    /**
     * 单个对象查询
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "one查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/findVoOne", method = RequestMethod.POST)
    public ReturnResult findVoOne(KwTeacherMessageVo kwTeacherMessageVo) {
        return new ReturnResult(kwTeacherMessageService.findVoOne(kwTeacherMessageVo));
    }

    /**
     * 跳转添加或编辑界面
     *
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "跳转添加或编辑界面", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/getEdit", method = RequestMethod.GET)
    public ModelAndView getEdit(KwTeacherMessageVo kwTeacherMessageVo) {
        ModelAndView view = new ModelAndView("/work/kwmanagement/kwteachermessage/kwTeacherMessageEdit");
        if (StringUtils.isNotBlank(kwTeacherMessageVo.getId())) {
            view.addObject(kwTeacherMessageService.findVoOne(kwTeacherMessageVo));
        }
        return view;
    }

    /**
     * 保存或更新
     *
     * @param request 请求对象
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "保存或更新对象", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/addOrUpdate", method = RequestMethod.POST)
    public ReturnResult addOrUpdate(HttpServletRequest request, KwTeacherMessageVo kwTeacherMessageVo) {
        return kwTeacherMessageService.addOrUpdate(kwTeacherMessageVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件逻辑删除
     *
     * @param request 请求对象
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "逻辑删除对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/remove", method = RequestMethod.GET)
    public ReturnResult remove(HttpServletRequest request, KwTeacherMessageVo kwTeacherMessageVo) {
        return kwTeacherMessageService.remove(kwTeacherMessageVo, acceptCurrentUser(request));
    }

    /**
     * 根据条件物理删除
     *
     * @param request 请求对象
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "物理对象对象", businessType = BusinessType.DELETE, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/delete", method = RequestMethod.GET)
    public ReturnResult delete(HttpServletRequest request, KwTeacherMessageVo kwTeacherMessageVo) {
        return kwTeacherMessageService.delete(kwTeacherMessageVo, acceptCurrentUser(request));
    }

    /**
     * 分配老师
     *
     * @param request 请求对象
     * @param kwTeacherMessageVo 接受参数对象
     * @return ReturnResult
     * @author han jun
     * @date 2019-11-26 11:25:40
     */
    @BaseLog(module = "考务教师表详细表", classz = "考务教师表详细表", methods = "分配老师", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/startDistributeTeacher", method = RequestMethod.POST)
    public ReturnResult startDistributeTeacher(HttpServletRequest request, KwTeacherMessageVo kwTeacherMessageVo) {
        return kwTeacherMessageService.startDistributeTeacher(kwTeacherMessageVo, acceptCurrentUser(request));
    }

    /**
     * 导出某场考试 老师分配情况
     * @param response
     * @author hanjun
     * @date 2019/9/3 13:43
     */
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/exportTeacher")
    public void exportTeacher(HttpServletResponse response,KwTeacherMessageVo kwTeacherMessageVo) {
        List<KwTeacherStExportVo> list = kwTeacherMessageService.exportTeacherList(kwTeacherMessageVo);
        // 导出操作
        EasyPoiUtil.exportExcel(list, "老师分配情况", "老师分配情况", KwTeacherStExportVo.class, "老师分配情况.xls", response);
    }


    /**
     * 更新监巡考老师分配情况
     * @param request
     * @author hanjun
     * @date 2019/9/3 13:43
     */
    @RequestMapping(value = "/work/kwmanagement/kwteachermessage/aupdateTeacherMessage")
    public ReturnResult aupdateTeacherMessage(HttpServletRequest request,KwTeacherMessageVo kwTeacherMessageVo) {
        return kwTeacherMessageService.updateKwTeacherMessage(kwTeacherMessageVo, acceptCurrentUser(request));
    }

}